﻿

namespace SvGame.Objects;

public partial class Player
{
    public string DbKey() => "players";
    public string Uid() => Puid.ToString();
    public bool Exist() => Puid != 0;

    [JsonIgnore]
    public MySession Session { get; set; } = new MySession();
    public int Send<T>(T msg, EProtocolResult ecode = EProtocolResult.成功) where T : gpb.IMessage
        => Session.Send(msg, ecode);

    // 上次存盘时间
    [JsonIgnore]
    public long TicksAutoSave { get; set; } = DateTime.Now.Ticks;
    public void TicksAutoSaveSet()
    {
        TicksAutoSave = DateTime.Now.AddMinutes(10 + Rd(5)).Ticks;
    }

    // 是否在线
    [JsonIgnore]
    public bool Online { get; set; } = false;
    // 断线时间
    [JsonIgnore]
    public long TicksDisconnect { get; set; } = 0;

    // 上次计算年龄时间
    [JsonIgnore]
    public long TicksUpdateAge { get; set; } = DateTime.Now.Ticks;

}
